# encoding=utf-8

# ---------------------------------------------------------------------------------------------------------
#
#  自定义的 pandoc filter，pandoc 在将 word 转换成 markdown 时，生成的图片链接不理想，所以重写了生成图片的逻辑
#
# ---------------------------------------------------------------------------------------------------------

from pandocfilters import RawBlock, toJSONFilter, Image, attributes


def custom_filter(key, value, format, meta):
    if key == 'Image':
        [_, _, c] = value
        if 'gfm' == format:
            return Image(attributes({}), [], c)


if __name__ == '__main__':
    toJSONFilter(custom_filter)
